import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
  list = '/nurse_user_orders/nurseUserOrders/list',
  listAll = '/nurse_user_orders/nurseUserOrders/listAll',
  save = '/nurse_user_orders/nurseUserOrders/add',
  edit = '/nurse_user_orders/nurseUserOrders/edit',
  deleteOne = '/nurse_user_orders/nurseUserOrders/delete',
  deleteBatch = '/nurse_user_orders/nurseUserOrders/deleteBatch',
  importExcel = '/nurse_user_orders/nurseUserOrders/importExcel',
  exportXls = '/nurse_user_orders/nurseUserOrders/exportXls',
  copyOrder = '/nurse_user_orders/nurseUserOrders/copyOrder',
  refund = '/nurse_user_orders/nurseUserOrders/refund',
  nurseUserOrdersDetailList = '/nurse_user_orders/nurseUserOrders/listNurseUserOrdersDetailByMainId',
  nurseUserOrdersDetailSave = '/nurse_user_orders/nurseUserOrders/addNurseUserOrdersDetail',
  nurseUserOrdersDetailEdit = '/nurse_user_orders/nurseUserOrders/editNurseUserOrdersDetail',
  nurseUserOrdersDetailDelete = '/nurse_user_orders/nurseUserOrders/deleteNurseUserOrdersDetail',
  nurseUserOrdersDetailDeleteBatch = '/nurse_user_orders/nurseUserOrders/deleteBatchNurseUserOrdersDetail',
  nurseUserOrdersCommentList = '/nurse_user_orders/nurseUserOrders/listNurseUserOrdersCommentByMainId',
  nurseUserOrdersCommentSave = '/nurse_user_orders/nurseUserOrders/addNurseUserOrdersComment',
  nurseUserOrdersCommentEdit = '/nurse_user_orders/nurseUserOrders/editNurseUserOrdersComment',
  nurseUserOrdersCommentDelete = '/nurse_user_orders/nurseUserOrders/deleteNurseUserOrdersComment',
  nurseUserOrdersCommentDeleteBatch = '/nurse_user_orders/nurseUserOrders/deleteBatchNurseUserOrdersComment',
  nurseUserOrdersPreList = '/nurse_user_orders/nurseUserOrders/listNurseUserOrdersPreByMainId',
  nurseUserOrdersPreSave = '/nurse_user_orders/nurseUserOrders/addNurseUserOrdersPre',
  nurseUserOrdersPreEdit = '/nurse_user_orders/nurseUserOrders/editNurseUserOrdersPre',
  nurseUserOrdersPreDelete = '/nurse_user_orders/nurseUserOrders/deleteNurseUserOrdersPre',
  nurseUserOrdersPreDeleteBatch = '/nurse_user_orders/nurseUserOrders/deleteBatchNurseUserOrdersPre',
  nurseUserOrdersNursesNewList = '/nurse_user_orders/nurseUserOrders/listNurseUserOrdersNursesNewByMainId',
  nurseUserOrdersNursesNewSave='/nurse_user_orders/nurseUserOrders/addNurseUserOrdersNursesNew',
  nurseUserOrdersNursesNewEdit='/nurse_user_orders/nurseUserOrders/editNurseUserOrdersNursesNew',
  nurseUserOrdersNursesNewDelete = '/nurse_user_orders/nurseUserOrders/deleteNurseUserOrdersNursesNew',
  nurseUserOrdersNursesNewDeleteBatch = '/nurse_user_orders/nurseUserOrders/deleteBatchNurseUserOrdersNursesNew',
}
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;

/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;

/**
 * 退款接口
 * @param params
 */
export const refund = (params) =>
  defHttp.get({ url: Api.refund, params });


/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({ url: Api.list, params });

/**
 * 列表接口-全部数据
 * @param params
 */
export const listAll = (params) =>
  defHttp.get({ url: Api.listAll, params });

/**
 * 根据type参数动态选择列表接口
 * @param params
 * @param hasType 是否有type参数
 */
export const listByType = (params, hasType: boolean) => {
  const url = hasType ? Api.list : Api.listAll;
  return defHttp.get({ url, params });
};

/**
 * 删除单个
 */
export const deleteOne = (params, handleSuccess) => {
  return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({ url: url, params });
}

/**
 * 复制订单
 * @param params { id: 订单ID, num: 复制数量 }
 */
export const copyOrder = (params) => {
  return defHttp.post({ url: Api.copyOrder, params }, { joinParamsToUrl: true });
}
/**
 * 列表接口
 * @param params
 */
export const nurseUserOrdersDetailList = (params) => {
  if (params['orderId']) {
    return defHttp.get({ url: Api.nurseUserOrdersDetailList, params });
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const nurseUserOrdersDetailDelete = (params, handleSuccess) => {
  return defHttp.delete({ url: Api.nurseUserOrdersDetailDelete, params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const nurseUserOrdersDetailDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.nurseUserOrdersDetailDeleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const nurseUserOrdersDetailSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.nurseUserOrdersDetailEdit : Api.nurseUserOrdersDetailSave;
  return defHttp.post({ url: url, params });
}
/**
 * 导入
 */
export const nurseUserOrdersDetailImportUrl = '/nurse_user_orders/nurseUserOrders/importNurseUserOrdersDetail'

/**
 * 导出
 */
export const nurseUserOrdersDetailExportXlsUrl = '/nurse_user_orders/nurseUserOrders/exportNurseUserOrdersDetail'
/**
 * 列表接口
 * @param params
 */
export const nurseUserOrdersCommentList = (params) => {
  if (params['orderId']) {
    return defHttp.get({ url: Api.nurseUserOrdersCommentList, params });
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const nurseUserOrdersCommentDelete = (params, handleSuccess) => {
  return defHttp.delete({ url: Api.nurseUserOrdersCommentDelete, params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const nurseUserOrdersCommentDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.nurseUserOrdersCommentDeleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const nurseUserOrdersCommentSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.nurseUserOrdersCommentEdit : Api.nurseUserOrdersCommentSave;
  return defHttp.post({ url: url, params });
}
/**
 * 导入
 */
export const nurseUserOrdersCommentImportUrl = '/nurse_user_orders/nurseUserOrders/importNurseUserOrdersComment'

/**
 * 导出
 */
export const nurseUserOrdersCommentExportXlsUrl = '/nurse_user_orders/nurseUserOrders/exportNurseUserOrdersComment'
/**
 * 列表接口
 * @param params
 */
export const nurseUserOrdersPreList = (params) => {
  if (params['orderId']) {
    return defHttp.get({ url: Api.nurseUserOrdersPreList, params });
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const nurseUserOrdersPreDelete = (params, handleSuccess) => {
  return defHttp.delete({ url: Api.nurseUserOrdersPreDelete, params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const nurseUserOrdersPreDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.nurseUserOrdersPreDeleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const nurseUserOrdersPreSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.nurseUserOrdersPreEdit : Api.nurseUserOrdersPreSave;
  return defHttp.post({ url: url, params });
}
/**
 * 导入
 */
export const nurseUserOrdersPreImportUrl = '/nurse_user_orders/nurseUserOrders/importNurseUserOrdersPre'

/**
 * 导出
 */
export const nurseUserOrdersPreExportXlsUrl = '/nurse_user_orders/nurseUserOrders/exportNurseUserOrdersPre'

/**
 * 列表接口
 * @param params
 */
export const nurseUserOrdersNursesNewList = (params) => {
  if(params['orderId']){
    return defHttp.get({url: Api.nurseUserOrdersNursesNewList, params});
  }
  return Promise.resolve({});
}
/**
 * 删除单个
 */
export const nurseUserOrdersNursesNewDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.nurseUserOrdersNursesNewDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const nurseUserOrdersNursesNewDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.nurseUserOrdersNursesNewDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  nurseUserOrdersNursesNewSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.nurseUserOrdersNursesNewEdit : Api.nurseUserOrdersNursesNewSave;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const nurseUserOrdersNursesNewImportUrl = '/nurse_user_orders/nurseUserOrders/importNurseUserOrdersNursesNew'

/**
 * 导出
 */
export const nurseUserOrdersNursesNewExportXlsUrl = '/nurse_user_orders/nurseUserOrders/exportNurseUserOrdersNursesNew'